// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import ElementUI from 'element-ui';
import App from './App'
import router from './router'
import VueRouter from "vue-router";
import 'element-ui/lib/theme-chalk/index.css';
import PageContainer from "./components/PageContainer";
import EmpHead from "./components/EmpHead";
import EmpLeft from "./components/EmpLeft";
import EmpMain from "./components/EmpMain";
import 'element-ui/lib/theme-chalk/index.css';
import store from './store/store.js'
import TrainPlanManage from "./components/TrainingManagePage/TrainPlanManage";
import TrainPlanAdd from "./components/TrainingManagePage/TrainPlanAdd";
import CourseCheckAndUpdate from "./components/TrainingManagePage/CourseCheckAndUpdate";
import AddTrainCourse from "./components/TrainingManagePage/AddTrainCourse";
import TrainCourseTalkManage from "./components/TrainingManagePage/TrainCourseTalkManage";
import EmpTrainManage from "./components/TrainingManagePage/EmpTrainManage";
import CreateEmpAccount from "./components/TrainingManagePage/CreateEmpAccount";
import EmpTrainGradeInput from "./components/TrainingManagePage/EmpTrainGradeInput";
import TrainClassManage from "./components/TrainingManagePage/TrainClassManage";
import ClassPersonStatistics from "./components/TrainingManagePage/ClassPersonStatistics";
import AddTrainClass from "./components/TrainingManagePage/AddTrainClass";
import SysManageAdd from "./components/TrainingManagePage/SysManageAdd";
import SysNoticeAdd from "./components/TrainingManagePage/SysNoticeAdd";
import SysNoticePage from "./components/TrainingManagePage/SysNoticePage";
import EmpOneselfInfo from "./components/EmpTrainingPage/EmpOneselfInfo";
import EmpOneselfTrainCourse from "./components/EmpTrainingPage/EmpOneselfTrainCourse";
import OnlineCoursesStudy from "./components/EmpTrainingPage/OnlineCoursesStudy";
import VideoPage from "./components/EmpTrainingPage/VideoPage";
import ExamingPage from "./components/EmpTrainingPage/ExamingPage";
import TrainingMainPage from "./components/EmpTrainingPage/TrainingMainPage";
import Login from "./components/Login";

//视频播放的组件
import VueCoreVideoPlayer from 'vue-core-video-player'
Vue.use(VueCoreVideoPlayer, {
  lang: 'zh-CN'
})
//
Vue.use(VueRouter)
Vue.config.productionTip = false
Vue.component("VideoPage",VideoPage)
Vue.use(ElementUI);
Vue.component("Login",Login)
Vue.component("TrainingMainPage",TrainingMainPage)
Vue.component("ExamingPage",ExamingPage);
Vue.component("OnlineCoursesStudy",OnlineCoursesStudy);
Vue.component("EmpOneselfTrainCourse",EmpOneselfTrainCourse);
Vue.component("EmpOneselfInfo",EmpOneselfInfo);
Vue.component("SysNoticePage",SysNoticePage);
Vue.component("SysNoticeAdd",SysNoticeAdd);
Vue.component("SysManageAdd",SysManageAdd);
Vue.component("PageContainer",PageContainer);
Vue.component("EmpHead",EmpHead);
Vue.component("EmpLeft",EmpLeft);
Vue.component("EmpMain",EmpMain);
Vue.component("TrainPlanManage",TrainPlanManage);
Vue.component("TrainPlanAdd",TrainPlanAdd);
Vue.component("CourseCheckAndUpdate",CourseCheckAndUpdate);
Vue.component("AddTrainCourse",AddTrainCourse);
Vue.component("TrainCourseTalkManage",TrainCourseTalkManage);
Vue.component("EmpTrainManage",EmpTrainManage);
Vue.component("CreateEmpAccount",CreateEmpAccount);
Vue.component("EmpTrainGradeInput",EmpTrainGradeInput)
Vue.component("TrainClassManage",TrainClassManage);
Vue.component("ClassPersonStatistics",ClassPersonStatistics);
Vue.component("AddTrainClass",AddTrainClass)


//路由导航 这就像一个安检员一样 你要去那个路由 直接进入就可以
/*这里对router.beforeEach方法的每个参数做简要的解释。

“to”: 即将要进入的目标 路由对象;（这个对象中包含name，params，meta等属性）

"from": 当前导航正要离开的路由对象；（这个对象中包含name，params，meta等属性）

“next”: Function: 确保要调用 next 方法，否则钩子就不会被 resolved。这个当中还可以传一些参数，具体可以看官方文档。*/
router.beforeEach((to, from, next) => {
  //用你的方式获取登录的用户信息
 // const userinfo = localStorage.userinfo
  if(to.name === 'Login'){
    //如果存在用户信息，或者进入的页面是登录页面，则直接进入
    next()
  };
  if(to.name==='TrainingMainPage'){
    next()
  };
  if(to.name==='PageContainer'){
    next()
  }
  if(to.name==='VideoPage'){
    next()
  }
  if(to.name==='ExamingPage'){
    next()
  }

  /*else {
    //不存在用户信息则说明用户未登录，跳转到登录页面，带上当前的页面地址，登录完成后做回跳，
    //如未登录用户进入用户中心的页面地址，检测到未登录，
    //自动跳转到登录页面，并且带上用户中心的页面地址，登录完成后重新跳到个人中心页面。
    next({
      name: 'Login',
      query: {
        redirect: to.path
      }
    })
  }*/
})

/* eslint-disable no-new
在引入 Element 时，可以传入一个全局配置对象。该对象目前支持 size 与 zIndex 字段。
size 用于改变组件的默认尺寸，zIndex 设置弹框的初始 z-index（默认值：2000）。按照引入 Element 的方式，具体操作如下：
 Vue.use(Element, { size: 'small', zIndex: 3000 });*/
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
